'''
for while循环
'''

# 1. while循环
n = 100
sum = 0
counter = 1

if 0:
    while counter<=n:
        sum = sum+counter
        counter+=1
    print('sum of 1 untill{}:{}'.format(n,sum))

# 2.for 循环
languages = ['c','c++','Go','python']

if 0:
    for x in languages:
        print("x:{}".format(x))

    em_people = ['gsh','huolinfei','xiaohuohuo','xiye']
    for one in em_people:
        if(one == 'xiye'):
            print("{} in there".format(one))
        else:

            print("{} not in there".format(one))

# 2.1 range 函数介绍
# for 内禁止什么都不做
if 1:
        
    for i in range(5):
        print("range i :{}".format(i)) 

    print('')
    for x in range(2,7): #打印[2,7)的值
        print("range x :{}".format(x))   
    
    print('')
    for x in range(0,10,2): #打印[0,10) 值 间隔2打印一个，0 2 4 6 8 
        print("range x :{}".format(x))   

    print('')
    a = ['mary','had','a','little','lamb']
    it = iter(a) #创建迭代器对象
    for i in range(len(a)):
        print(next(it))
        # print(i,a[i])

    



